﻿using System;
using System.Collections.Generic;
using System.Text;
using SH;

namespace MTS
{

	class mtIPSServerCallback : mtOuterface<ImtIPSServerCallback>
    {
		public mtIPSServerCallback()
		{
			m_interfaceName = "mtIPSServerCallback";
			m_nClassID = ImtIPSServerCallback._classID;
		}

		protected override shErrorCode OnRequest(int nClassID, int nFuncID, string token, ref MTSSerializer sc)
        {
            shErrorCode ec = shErrorCode.sh_ec_NoInterface;

            switch (nFuncID)
            {

				case ImtIPSServerCallback.ImtIPSServerStationInfo:
                    {
						mtIpsStationInfo info = new mtIpsStationInfo();

						sc.serialize(info);

						ec = m_pCallback.OnIpsStationInfo(token, info);

					}
					break;
				case ImtIPSServerCallback.ImtIPSServerStationStatus:
					{
						mtIpsStationStatus req = new mtIpsStationStatus();

						sc.serialize(req);

						ec = m_pCallback.OnIpsStationStatus(token, req);
					}
					break;
				case ImtIPSServerCallback.ImtIPSServerGetIpsImageList:
					{
						mtIpsImageList imageList ;

						ec = m_pCallback.OnGetIpsImageList(token,out imageList);

						if(ec == shErrorCode.sh_ec_Success)
						{
							sc = new MTSSerializer();

							sc.serialize(imageList);
						}
					}
					break;

				case ImtIPSServerCallback.ImtIPSServerReqIpsTask:
					{
						mtIpsTask task ;

						string prn="";

						sc.serialize(ref prn);

						ec = m_pCallback.OnReqIpsTask(token, prn, out task);

						if (ec == shErrorCode.sh_ec_Success)
						{
							sc = new MTSSerializer();

							sc.serialize(task);
						}
					}
					break;
				case ImtIPSServerCallback.ImtIPSServerSubmitConclusion:
					{
						mtIpsResult result = new mtIpsResult();

						sc.serialize(result);

						ec = m_pCallback.OnSubmitConclusion(token, result);

						if (ec == shErrorCode.sh_ec_Success)
						{
							sc = new MTSSerializer();
						}
					}
					break;
				case ImtIPSServerCallback.ImtIPSServerSubmitImageOperation:
					{
						List<mtIpsImageOperation> vecOperation = new List<mtIpsImageOperation>();
						List<mtIpsImageOperationResult> vecResult ;
						sc.serialize(vecOperation);

						ec = m_pCallback.OnSubmitImageOperation(token, vecOperation,out vecResult);

						if (ec == shErrorCode.sh_ec_Success)
						{
							sc = new MTSSerializer();

							sc.serialize(vecResult);
						}
					}
					break;
				case ImtIPSServerCallback.ImtIPSServerReconComplete:
					{
						mtReconComplete req = new mtReconComplete();

						sc.serialize(req);

						ec = m_pCallback.OnReconComplete(token, req);
					}
					break;
				case ImtIPSServerCallback.ImtIPSServerRecognizeComplete:
					{
						mtRecognizeComplete info = new mtRecognizeComplete();

						sc.serialize(info);

						ec = m_pCallback.OnRecognizeComplete(token, info);

					}
					break;
				case ImtIPSServerCallback.ImtIPSServerStorageComplete:
					{
						mtStorageComplete info = new mtStorageComplete();
			
						sc.serialize(info);

						ec = m_pCallback.OnStorageComplete(token, info);

					}
					break;

				case ImtIPSServerCallback.ImtIPSServerQueryHistoryImageInfo:
					{
						mtPicCriteria req = new mtPicCriteria();
						List<mtPicinfo> rsp ;

						sc.serialize(req);

						ec = m_pCallback.OnQueryHistoryImageInfo(token, req, out rsp);

						if (ec == shErrorCode.sh_ec_Success)
						{
							sc = new MTSSerializer();

							sc.serialize(rsp);
						}
					}
					break;
				case ImtIPSServerCallback.ImtIPSServerGetResourceString:
					{
						string lang = "";
						string rsp;

						sc.serialize(ref lang);

						ec = m_pCallback.OnGetResourceString(token, lang, out rsp);

						if (ec == shErrorCode.sh_ec_Success)
						{
							sc = new MTSSerializer();

							sc.serialize(ref rsp);
						}
					}
					break;
				default:
                    return ec;
            }

            return ec;
        }
		
	}
}
